<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button class="get">get</button>
    <button class="post">post</button>
</body>
<script type="module">
    import { ajax } from "../js/ajax.js";

    var getBtn = document.getElementsByClassName("get")[0];
    var postBtn = document.getElementsByClassName("post")[0];

    getBtn.onclick = function () {
        var wd = ""; //全局变量  记录搜索的关键词   "" => 默认查询所有数据
        var col = "id"; // 全局变量  按哪个数据排序  默认按id排序
        var type = "asc"; //  全局变量  排序方式   默认升序
        var page = 1;   // 全局变量  记录页码(默认显示第一页)
        var size = 5;   // 全局变量  记录每页显示几条数据

        // debugger;

        // 回调函数 -> 把函数作为参数传到另一个函数中 让它在另一个函数中执行

        ajax({
            type: "get",
            url: "http://43.138.81.225/demo/php/searchGoodsOrderLimit.php",
            data: `wd=${wd}&col=${col}&type=${type}&page=${page}&size=${size}`,
            // async:true,
            dataType: "json",
            success: function (res) {
                console.log("请求成功", res);
            }
        })

        page++;
        ajax({
            type: "get",
            url: "http://43.138.81.225/demo/php/searchGoodsOrderLimit.php",
            data: {
                wd: wd,
                col,
                type,
                page: page,
                size,
            },
            // async:true,
            dataType: "json",
            success: function (res) {
                console.log("请求成功", res);
            }
        })
    }


    postBtn.onclick = function () {
        var acccount = "a123123";
        var pwd = "123123";

        ajax({
            type: "post",
            url: "http://43.138.81.225/demo/php/login_account.php",
            data: {
                account: acccount,
                pwd,
            },
            async: true,
            dataType: "json",
            success: function (res) {
                console.log("请求成功", res);
            }

        })
    }




</script>




</html>